package nullInvader.Test;
import static org.junit.Assert.*;

import java.awt.Point;
import java.util.ArrayList;
import java.util.concurrent.ConcurrentHashMap;

import nullInvader.Control.GameControl;
import nullInvader.Engine.*;

import org.junit.Before;
import org.junit.Test;

public class PlayerTest {

    ConcurrentHashMap<Point, Zone> hashMap;
    ArrayList<Point> point;
    Point p ;
    Map map;
    Player player;
    GameControl gameControl;
    ArrayList<Tower> towerList;
    ArrayList<UnitInfo> unitInfo;

    /**
     * setUp method that creates the necessary objects for testing correctly
     */
    @SuppressWarnings("serial")
    @Before
    public void setUp() {
	point = new ArrayList<Point>();
	hashMap = new ConcurrentHashMap<Point, Zone>() {
	};
	point.add(new Point(13, 14));
	p = new Point(1,1);
	unitInfo = new ArrayList<UnitInfo>();
	towerList = new ArrayList<Tower>();
	map = new Map(hashMap, "test", 13, 0, p, point, unitInfo,
		towerList);
	gameControl = new GameControl(null);
	player = new Player(map, 11, gameControl);
    }

    @Test
    public void testModifyCash() {
	player.modifyCash(10);
	assertTrue(player.getCash() == 10);
    }

    @Test
    public void testKill() {
	player.kill();
	assertTrue(player.kill());
    }

    @Test
    public void testcheckGameStatus() {
	assertTrue(player.checkGameStatus(10, 5) == 0);
	assertTrue(player.checkGameStatus(15, 0) == 1);
	assertTrue(player.checkGameStatus(0, 0) == 2);
    }
    
    @Test
    public void testGetCash() {
	player = new Player(map, 11, gameControl);
	assertTrue(player.getCash() == 0);
    }
    
    @Test
    public void testGetScore() {
	assertTrue(player.getScore() == 13000);
    }
}
